package com.ymttest.database.sqlwapper;

import com.ymt.database.SqlManager;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhoulei
 * @2018/09/19
 */
public class IntergratedProductMapper {
    SqlManager manage;

    public IntergratedProductMapper() {
        manage = new SqlManager("intpro");
    }

    public Map<String,Object> selectProductByProdId(String productId){
        List<Map> sProducts = manage
                .getSelectResults(
                        "com.ymttest.database.mapping.IntergratedProductMapper.selectProductByProdId",
                        productId);
        manage.commit();
        Map<String,Object> map = sProducts.get(0);
        return map;
    }

    public List<Map<String,Object>> selectCatalogsByProdId(String productId){
        List<Map<String,Object>> sProducts = manage
                .getSelectResults(
                        "com.ymttest.database.mapping.IntergratedProductMapper.selectCatalogsByProdId",
                        productId);
        manage.commit();
        return sProducts;
    }



    public List<Map<String,Object>> selectSellerLoginLimitAutoOnShevelByUserId(int userid){
        List<Map<String,Object>> SellerLoginLimitAutoOnShevel = manage
                .getSelectResults(
                        "com.ymttest.database.mapping.IntergratedProductMapper.selectSellerLoginLimitAutoOnShevelByUserId",
                        userid);
        manage.commit();
        return SellerLoginLimitAutoOnShevel;
    }

    public int deleteSellerLoginInfoByUserId(int userId){
        int i = manage.delete(
                "com.ymttest.database.mapping.IntergratedProductMapper.deleteSellerLoginInfoByUserId",
                userId
        );
        manage.commit();
        return i;
    }

    public List<Map<String,Object>> selectSpuPropertyByThirdCategoryId(int thirdCategoryId){
        List<Map<String,Object>> SpuProperty = manage
                .getSelectResults(
                        "com.ymttest.database.mapping.IntergratedProductMapper.selectSpuPropertyByThirdCategoryId",
                        thirdCategoryId);
        manage.commit();
        return SpuProperty;
    }

    public List<Map<String,Object>> selectSpuPropertyValByPropId(int propertyId){
        List<Map<String,Object>> SpuProperty = manage
                .getSelectResults(
                        "com.ymttest.database.mapping.IntergratedProductMapper.selectSpuPropertyByThirdCategoryId",
                        propertyId);
        manage.commit();
        return SpuProperty;
    }

    public Map<String,Object> selectSpuProductBySpuId(int spuId){
        List<Map<String,Object>> SpuProperty = manage
                .getSelectResults(
                        "com.ymttest.database.mapping.IntergratedProductMapper.selectSpuProductBySpuId",
                        spuId);
        manage.commit();

        return SpuProperty.get(0);
    }

    public int updateSellerLoginLimitAutoOnShevelAsSellerLoginLimitAutoOnShevelId(String SellerLoginLimitAutoOnShevelId, String ProcessStatus){
            Map m = new HashMap();
            m.put("SellerLoginLimitAutoOnShevelId", SellerLoginLimitAutoOnShevelId);
            m.put("ProcessStatus", ProcessStatus);
            int i = manage
                    .update("com.ymttest.database.mapping.IntergratedProductMapper.updateSellerLoginLimitAutoOnShevelAsSellerLoginLimitAutoOnShevelId",
                            m);
            manage.commit();
            // manage.close();
            return i;
    }
    public static void main(String args[]){
        Map<String,Object> list = new IntergratedProductMapper().selectSpuProductBySpuId(237330);
        System.out.println(list);
    }
}
